import keras
from keras.layers import Dense


class ForwardNeutronNetwork(keras.Model):
    """
    构建自定义前向神经网络
    """

    def __init__(self):
        # 调用 ForwardNeutronNetwork 的父类，执行相关参数的初始化
        super(ForwardNeutronNetwork, self).__init__()
        # 构建 3 个全连接层
        self.fc1 = Dense(units=64, activation='relu')
        self.fc2 = Dense(units=64, activation='relu')
        self.fc3 = Dense(units=1)

    def call(self, inputs, training=None, mask=None):
        # 在运行的时候将输入数据依次通过 3 个全连接层
        x = self.fc1(inputs)
        x = self.fc2(x)
        x = self.fc3(x)
        return x
